package com.fay.designPattern.pattern.create.singleton;

import java.util.concurrent.atomic.AtomicLong;

/**
 * @Title:
 * @Description:
 * @Author Fay Wang
 * @Date 2022/4/3 22:00
 * @Version 1.0
 */
public class IdGeneratorStatic {
    private AtomicLong id = new AtomicLong(0);
    private IdGeneratorStatic(){}

    private static class SingletonHolder {
        private static final IdGeneratorStatic instance = new IdGeneratorStatic();
    }

    public static IdGeneratorStatic getInstance() {
        return SingletonHolder.instance;
    }


    public long getId() {
        return id.incrementAndGet();
    }

}
